// pages/tree/tree.js
let get = require('../../utils/util')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    data:[],
    current:0
  },
  onLoad(){
    get("user/trees",{
      token:wx.getStorageSync("token")
    }).then(res=>{
      this.setData({
        data:res.data.data
      })
    })
  },
left(){
  let that = this
  if(that.data.current==0){
    this.setData({
      current:this.data.data.length-1
    })
  }else{
  this.setData({
    current:(Math.abs(that.data.current-1))%that.data.data.length
  })}
},
right(){
  let that = this
  this.setData({
    current:(that.data.current+1)%that.data.data.length
  })
}})